package view;

import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.util.Observer;
import java.util.Observable;
import model.*;

public class StatusViewport implements Observer
{

	private JFrame myWindow;
	private AvatarViewer aViewer;
	private StatsViewer sViewer;
	private InventoryViewer iViewer;
	private EquipmentViewer eViewer;
	private final Entity player;
	
	public StatusViewport(Model m)
	{
		player = m.getPlayerEntity();
		myWindow = new JFrame();
		aViewer = new AvatarViewer(player);
		sViewer = new StatsViewer(player);
		iViewer = new InventoryViewer(player);
		eViewer = new EquipmentViewer(player);
		myWindow.setLayout(new GridLayout(2,2));
		myWindow.add(aViewer);
		myWindow.add(sViewer);
		myWindow.add(iViewer);
		myWindow.add(eViewer);
		initiate(); 
	}
	
	private void initiate() //could be in the constructor?
	{
		myWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		myWindow.setSize(400,400);
		myWindow.setLocation(200,200);
		myWindow.setVisible(true);
	}
	
	public void close()
	{
		
	}
	
	public void update(Observable o, Object arg)
	{
		sViewer.update(player);
		iViewer.update(player);
		eViewer.update(player);
	}
}